//package com.cy.common.config;
//
//import org.apache.shiro.mgt.SecurityManager;
//
//import org.apache.shiro.realm.Realm;
//import org.apache.shiro.session.mgt.SessionManager;
//import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
//import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
//import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
//import org.apache.shiro.web.session.mgt.DefaultWebSessionManager;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//import java.util.LinkedHashMap;
//
//@Configuration//该注解描述类为一个配置对象，会交由spring管理
//public class SpringShiroConfig {
//
//    @Bean//配置session对象，将对话写入session
//    public SessionManager sessionManager() {
//        DefaultWebSessionManager sManager=
//                new DefaultWebSessionManager();
//        sManager.setGlobalSessionTimeout(60*60*1000);
//        //配置默认时长
//        return sManager;
//    }
//    @Bean
//    public SecurityManager securityManager(Realm realm,SessionManager sessionManager){
//        DefaultWebSecurityManager a=
//                new DefaultWebSecurityManager();
//        a.setRealm(realm);
//        a.setSessionManager(sessionManager);
//        return a;
//    }
//    @Bean
//    public ShiroFilterFactoryBean shiroFilterFactory(
//            SecurityManager securityManager){
//        ShiroFilterFactoryBean sfbean=new ShiroFilterFactoryBean();
//        //设置权限管理器
//        sfbean.setSecurityManager(securityManager);
//        //没有认证可以访问此认证地址
//       sfbean.setLoginUrl("/doLoginUI");
//
//        //========ok
//        //定义map指定过滤规则,可以匿名访问anon
//        LinkedHashMap<String,String> map=new LinkedHashMap<>();
//        map.put("/bower_components/**","anon");
//        map.put("/build/**","anon");
//        map.put("/dist/**","anon");
//        map.put("/plugins/**","anon");
//        map.put("user/doLogin","anon");
//        //登入界面
//        map.put("/doLogout","logout");
//        //登出功能
//        //除了匿名访问的资源,其它都要认证("authc")后访问
//        map.put("/**","authc");
//        sfbean.setFilterChainDefinitionMap(map);
//
//        return sfbean;
//    }
//    @Bean
//    public AuthorizationAttributeSourceAdvisor
//    authorizationAttributeSourceAdvisor(SecurityManager securityManager) {
//        AuthorizationAttributeSourceAdvisor advisor=
//                new AuthorizationAttributeSourceAdvisor();
//        advisor.setSecurityManager(securityManager);
//        return advisor;
//    }
//
//
//}
